package org.jeecg.modules.bigdatashow.controller;

import org.jeecg.modules.bigdatashow.entity.*;
import org.jeecg.modules.bigdatashow.service.GeneralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GeneralController {
    @Autowired
    private GeneralService generalService;

    @GetMapping(value = "/showList",produces = "application/json; charset=utf-8")
    public CommonResult showList(){
        List<General> list  = generalService.showList();
        if (list != null){
            return new CommonResult(200,"左1:总表的信息为:",list);
        }else {
            return new CommonResult(404,"未查询到信息:");
        }
    }
    @GetMapping(value = "/showSex",produces = "application/json; charset=utf-8")
    public CommonResult showSex(){
        Sex sex  = generalService.showSex();
        if (sex != null){
            return new CommonResult(200,"左2饼：男女性别的数量为:",sex);
        }else {
            return new CommonResult(404,"未查询到信息:");
        }
    }
    @GetMapping(value = "/showFrom",produces = "application/json; charset=utf-8")
    public CommonResult showFrom(){
        From from  = generalService.showFrom();
        if (from != null){
            return new CommonResult(200,"左3饼:游客来源的信息为:",from);
        }else {
            return new CommonResult(404,"未查询到信息:");
        }
    }

    @GetMapping(value = "/showAge",produces = "application/json; charset=utf-8")
    public CommonResult showAge(){
        Ages age  = generalService.showAge();
        if (age != null){
            return new CommonResult(200,"左4饼:各个年龄段的数量为:",age);
        }else {
            return new CommonResult(404,"未查询到信息:");
        }
    }
}
